\documentclass{article}
\usepackage{amsmath}  

\title{Programming Work 1}
\author{zza  student number 3220104322}
\date{\today}

\begin{document}

\maketitle

\section{Problem a}
We created the base class `EquationSolver` with three subclasses `Newton\_Method`, `Bisection\_Method`, and `Secant\_Method`. Contained in the header file `EquationSolver`, each problem is solved by passing in different function equations and parameters.

\begin{verbatim}
    class EquationSolver {
        protected:
            const Function& F;
        public:
            EquationSolver(const Function& F) : F(F) {}
            virtual double solve() = 0;
            ~EquationSolver() {}
    };
    class Bisection_Method : public EquationSolver {......};
    class Newton_Method : public EquationSolver {......};
    class Secant_Method : public EquationSolver {......};
\end{verbatim}

\section{Problem b}
The answers to the four questions are:

\[
    \frac{1}{x} - \tan(x) \text{ on } \left[0, \frac{\pi}{2}\right]
\]
The root is 0.860334.

\[
    \frac{1}{x} - 2^x \text{ on } [0, 1]
\]
The root is 0.641186.

\[
    2^{-x} + e^x + 2 \cos(x) - 6 \text{ on } [1, 3]
\]
The root is 1.82938.

\[
    \frac{x^3 + 4x^2 + 3x + 5}{2x^3 - 9x^2 + 18x - 2} \text{ on } [0, 4]
\]
The root is 0.117877.

\section{Problem c}
\[
    x = \tan(x)
\]
The root near 4.5 is 4.49341, and the one near 7.7 is 7.72525.

\section{Problem d}
\[
    \sin\left(\frac{x}{2}\right) - 1 \text{ with } x_0 = 0, x_1 = \frac{\pi}{2}
\]
The root is 3.1388.

\[
    e^x - \tan(x) \text{ with } x_0 = 1, x_1 = 1.4
\]
The root is 1.30633.

\[
    x^3 - 12x^2 + 3x + 1 \text{ with } x_0 = 0, x_1 = -0.5
\]
The root is -0.188685.\\
If the initial value chosen is too far away or the slope changes too much, it may result in convergence to the wrong root or no convergence at all. For example, if the function changes more in one segment and less in the other, the secant method may iterate quickly in the former and miss the other roots.

\section{Problem e}
The goal of \( h \) is to find the root of the following equation:
\[
    \sin^{-1}(x) + x \sqrt{1 - x^2} + 1.24 - 0.5 \pi
\]
The roots by all three methods are 0.17.

\section{Problem f}

\subsection{a}
We put \( 33^\circ \) as the initial point into Newton's method and use the root of the solution to verify whether \( \alpha \) is \( 33^\circ \). The root is \( 32.97^\circ \), therefore verified.

\subsection{b}
The \( \alpha \) still is \( 33.17^\circ \).

\subsection{c}
The initial values are \( 33^\circ \), \( 150^\circ \).\\
The root is \( 168.59^\circ \).\\
The reason is similar to Problem d.

\end{document}
